﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using System.Configuration;
using System.Web.Security;

namespace Kis2012.Controllers
{
    public class DataStorage
    {
        private static DataStorage ds = null;
        private static System.Nullable<Guid> sid = null;

        public ProjectDBDataContext DB { get; set; }

        public static DataStorage GetInstance()
        {
            if (ds == null)
                ds = new DataStorage();
            return ds;
        }

        public DataStorage()
        {
            DB = new ProjectDBDataContext();
        }

        public System.Nullable<Guid> SessionID
        {
            get
            {
                return sid;
            }

            set
            {
                sid = value;
                if (value == null)
                    FormsAuthentication.SignOut();
                else
                    FormsAuthentication.SetAuthCookie(value.ToString(), false);
            }
        } 
    }
}
